# -*- coding: utf-8 -*-
# @Time    : 2022/5/25 22:49
# @Author  : liuzehai~
# @Email   : 1129309473@qq.com
# @File    : page_duobaoqibing.py
# -*- coding: utf-8 -*-
# @Time    : 2022/5/24 16:24
# @Author  : liuzehai~
# @Email   : 1129309473@qq.com
# @File    : sales_duobaoqibing_page.py
from selenium.webdriver.common.by import By

from page.page_font_login import LoginPage

from selenium import webdriver
from time import sleep
class AddDuoBao(LoginPage):
    def setUp(self) -> None:
        self.driver = webdriver.Chrome()
        self.driver.get("http://192.168.4.54:8081/upload/admin")
    def cuxi(self):
    # 操作方法
        self.driver.find_element(By.CSS_SELECTOR, "#menu-ul > li.collapse.lis.ico_2").click()
        sleep(3)
    def duobao(self):
        self.driver.find_element(By.XPATH, r"//*[@id='menu-ul']/li[2]/ul/li[1]/a").click()
        #退出菜单的frame
        self.driver.switch_to.parent_frame()
        # 切入主界面的frame
        self.driver.switch_to.frame("main-frame")
        #添加夺宝奇兵
    def addduobao(self):
        self.driver.find_element(By.XPATH, "/html/body/h1/span[1]/a").click()
        sleep(2)
    #输入活动名称
    def input_name(self):
        self.driver.find_element(By.NAME, "snatch_name").send_keys("夺宝奇兵")
    #点击搜索
    def search(self):
        self.driver.find_element(By.XPATH, "/html/body/div[1]/form/table/tbody/tr[2]/td[2]/input[2]").click()
    #输入描述
    def input_desc(self):
        self.driver.find_element(By.NAME, "desc").send_keys("快来买")
        sleep(3)
    #点击确定添加
    def sure_btn(self):
        self.driver.find_element(By.XPATH, "/html/body/div[1]/form/table/tbody/tr[11]/td/input[1]").click()
        sleep(3)
    def get_page(self):
        self.driver.get("http://192.168.4.54:8081/upload/")
    def input_keys(self):
        self.driver.find_element(By.XPATH, "//*[@id='keyword']").send_keys("毛衣外套")
    def search_btn(self):
        self.driver.find_element(By.XPATH, "//*[@id='searchForm']/span[2]/input").click()
    def photo(self):
        self.driver.find_element(By.XPATH, "//*[@id='compareForm']/div/div/a/img").click()
        sleep(2)
        current = self.driver.current_url
        current_expented = "http://192.168.4.54:8081/upload/goods.php?id=134"
        # 断言

    #汇总
    def admit(self):
        self.cuxi()
        self.duobao()
        self.addduobao()
        self.input_name()
        self.search()
        self.input_desc()
        self.sure_btn()
        self.get_page()
        self.input_keys()
        self.search_btn()
        self.photo()